import request from '@/utils/request'

/**
 * 获取全部字典类型列表
 */
const listDictType = function(data) {
  return request({
    url: '/dict/listDictType',
    method: 'post',
    data: data
  })
}
/**
 * 更新字典类型
 */
const updateDict = function(dict) {
  return request({
    url: '/dict/updateDict',
    method: 'post',
    data: dict
  })
}
/**
 * 添加字典
 */
const addDict = function(dict) {
  return request({
    url: '/dict/addDict',
    method: 'post',
    data: dict
  })
}
/**
 * 添加字典类型
 */
const deleteDictType = function(id) {
  return request({
    url: '/dict/deleteDictType',
    method: 'post',
    data: {
      id: id
    }
  })
}

/**
 * 分页获取字典项
 */
const listDictItem = function(pageNum, pageSize, pid) {
  return request({
    url: '/dict/listDictItem?pageNum=' + pageNum + '&pageSize=' + pageSize,
    method: 'post',
    data: {
      pid: pid
    }
  })
}

/**
 * 添加字典类型，支持批量删除
 */
const deleteDictItem = function(ids) {
  return request({
    url: '/dict/deleteDictItem',
    method: 'post',
    data: {
      ids: ids
    }
  })
}

export const dictApi = {
  deleteDictItem: deleteDictItem,
  listDictItem: listDictItem,
  listDictType: listDictType,
  updateDict: updateDict,
  addDict: addDict,
  deleteDictType: deleteDictType
}
